--纵驭人心
local zongyurenxin = fk.CreateSkill {
    name = "mcdh_zongyurenxin",
}

local U = require "packages/utility/utility"
local lib = require "packages/mcdh/lib"

zongyurenxin:addEffect('active',{
    can_use = function(self, player)
        return player:usedSkillTimes(self.name, Player.HistoryPhase) == 0
    end,
    min_card_num = 1,
    card_filter =function (self,player, to_select, selected)
        return not player:prohibitDiscard(Fk:getCardById(to_select))
    end,
    target_num = 2,
    target_filter = function(self, player,to_select, selected)
        if #selected == 0 then
            return to_select ~= player
        elseif #selected == 1 then
            local target = to_select
            local from = selected[1]
            return from:inMyAttackRange(target)
        end
    end,
    on_use = function (self, room, effect)
        local player = effect.from
        local target =effect.tos[1]
        local cards = effect.cards
        local num = #cards
        room:throwCard(cards, self.name, player, player)
        local use = room:askForUseCard(target, "slash", "slash", "#mcdh_zongyurenxin-use", true, {must_targets = {effect.tos[2].id},bypass_times = true,})
        if use then
            room:useCard(use)
            cards = table.filter(cards,function (p)
                return room:getCardArea(p) == Card.DiscardPile
            end)--只会获得还在弃牌堆的
            room:obtainCard(target, cards, true, fk.ReasonJustMove)
        else
            room:askForDiscard(target,num,num,false,self.name,false)
            room:loseHp(player, 1, self.name)
        end
    end
})

Fk:loadTranslationTable {
    ["mcdh_zongyurenxin"] = "纵驭人心",
    [":mcdh_zongyurenxin"] = "出牌阶段限一次，你可以弃置任意数量的手牌，令一名其他角色对其攻击范围内你选择的另一名角色使用一张【杀】，然后获得你弃置的牌；否则其弃置等量的手牌（不足则全弃），然后你失去1点体力。",
    ["#mcdh_zongyurenxin-use"] = "纵驭人心：对指定的角色使用一张【杀】并获得弃置的牌，否则弃置等量的手牌（不足则全弃）",
}

return zongyurenxin